#!/bin/bash
set -xeuo pipefail
set -o errexit

# 注册备份还原仓库 repoHdfs.sh 来完成

curl -XDELETE "http://localhost:9200/_snapshot/hdfs/snapshot_2020120*?pretty"
docker exec -ti hdfs-namenode hdfs dfs -rm -r /elastic_hdfs_repository/* || true

#详细的配置参考 backup.sh
#此处所有索引备份下
curl -XPUT "http://localhost:9200/_snapshot/hdfs/snapshot_20201204?pretty&wait_for_completion=true" -H 'Content-Type: application/json' -d'
{
}
'
#查看备份状态
curl -XGET "http://localhost:9200/_snapshot/hdfs/snapshot_20201204?pretty"

docker exec -ti hdfs-namenode hdfs dfs -ls /elastic_hdfs_repository
:<<EOF
$ docker exec -ti hdfs-namenode hdfs dfs -ls /elastic_hdfs_repository
WARNING: HADOOP_PREFIX has been replaced by HADOOP_HOME. Using value of HADOOP_PREFIX.
Found 5 items
-rw-r--r--   1 elasticsearch supergroup        851 2020-12-08 03:17 /elastic_hdfs_repository/index-0
-rw-r--r--   1 elasticsearch supergroup          8 2020-12-08 03:17 /elastic_hdfs_repository/index.latest
drwxr-xr-x   - elasticsearch supergroup          0 2020-12-08 03:17 /elastic_hdfs_repository/indices
-rw-r--r--   1 elasticsearch supergroup      28893 2020-12-08 03:17 /elastic_hdfs_repository/meta-eR7aaVX3R82PS02Fv4sX8A.dat
-rw-r--r--   1 elasticsearch supergroup        366 2020-12-08 03:17 /elastic_hdfs_repository/snap-eR7aaVX3R82PS02Fv4sX8A.dat
EOF
